
********************************************************************************
*********						 AFIG G7	-I-10 W EXPRESSLANES TRIP      *********
*********								DENSITY DURING AM PEAK         *********
********************************************************************************



*******************************************************************************
****						PANEL A										*******
*******************************************************************************
 
 
use ".\data\clean\I10W_laneuse_dataset_15nov14_wcensus", clear

drop hour min time 
gen hour=hh(exit_time)
gen min=mm(exit_time)
gen sec=ss(exit_time)

drop if weekend==1
keep if inlist(hour,5,6,7,8,9)
drop if holiday==1

drop if ELspeed==.

keep if acct_type=="PRIVATE"&occupancy~="HOV-3"
drop if charged_toll==0
keep if exit_plaza=="WT06"

gen time=hour+min/60+sec/(60*60)
g monthgroup=cond(date<td(04apr2013),1, ///
		cond(entry_month==5,2, ///
			cond(entry_month==8,3,.)))
kdensity time , kernel(epa) gen(t1_all epa_all) bw(.05) nograph n(100)
kdensity time if monthgroup==1, kernel(epa) gen(t1_1 epa_1) bw(.05) nograph n(100)
kdensity time if monthgroup==2 , kernel(epa) gen(t1_2 epa_2) bw(.05) nograph n(100)
kdensity time if monthgroup==3 , kernel(epa) gen(t1_3 epa_3) bw(.05) nograph n(100)

/*
graph twoway (line epa t1 if t1<=9, lcolor(black) lpattern(solid) ytitle(Smoothed Density) /// 
	xtitle("Hour of Morning Peak") ///
	xline(7, lcolor(gs5) lpattern(shortdash)) ///
	xline(8, lcolor(gs5) lpattern(shortdash)) ///
	xline(8.5, lcolor(gs10) lpattern(shortdash)) ///
	scheme(s1mono) plotregion(style(none))) ///
	,  /// title("SOV Demand Bunching on Exit Time, Plaza 6") ///
	xlabel(5 "5 a.m." 6 "6 a.m." 7 "7 a.m." 8 "8 a.m." 9 "9 a.m." , labsize(small) angle(45)) ///
	xtick(5 6 7 8 9) xmtick(5.5 6.5 7.5 8.5 ) ///
	 name(panela, replace)
*/
graph twoway (line epa_all t1_all if t1_all<=9, lcolor(gray) lpattern(solid) lw(thick)) ///
	(line epa_1 t1_1 if t1_1<=9, lcolor(black) lpattern(solid)) /// 
	(line epa_2 t1_2 if t1_2<=9, lcolor(black) lpattern(dash) ) /// 
	(line epa_3 t1_3 if t1_3<=9, lcolor(gray) lpattern(dot) ) ///
	, /// 
	xtitle("Hour of Morning Peak")  ytitle("Smoothed Density") ///
	xline(7, lcolor(gs5) lpattern(shortdash)) ///
	xline(8, lcolor(gs5) lpattern(shortdash)) ///
	xline(8.5, lcolor(gs10) lpattern(shortdash)) ///
	scheme(s1mono) plotregion(style(none)) ///
	legend(label(2 "First Month") label(3 "Third Month") label(4 "Sixth Month") label(1 "Full Sample") ///
	ring(0) position(11) rows(4) cols(1) region(lwidth(none))) ///
	  /// title("SOV Demand Bunching on Exit Time, Plaza 6") ///
	xlabel(5 "5 a.m." 6 "6 a.m." 7 "7 a.m." 8 "8 a.m." 9 "9 a.m." , labsize(small) angle(45)) ///
	xtick(5 6 7 8 9) xmtick(5.5 6.5 7.5 8.5 ) ///
	 name(panelb, replace)
 
graph export ".\results\revision1\bunching_by_month.png", width(2550) replace


 use ".\data\clean\HV_ML_reliab", clear
keep if fwy==10&dir=="W"
format date %d
sort date hour
tempfile temp2
save `temp2'


use ".\data\clean\I10W_laneuse_dataset_15nov14_wcensus", clear

sort date hour
merge m:1 date hour using `temp2', keep(1 3) nogen 
drop hour min time 
gen hour=hh(exit_time)
gen min=mm(exit_time)
gen sec=ss(exit_time)

drop if weekend==1
keep if inlist(hour,5,6,7,8,9)
drop if holiday==1
gen EL_TT=dist/ELspeed
gen ML_TT=dist/MLspeed
gen MP=inlist(hour,5,6,7,8)&weekend==0
gen TT_dif_hr=ML_TT-EL_TT
drop if ELspeed==.
gen WTP2=charged_toll/TT_dif_hr
keep if acct_type=="PRIVATE"&occupancy~="HOV-3"
drop if charged_toll==0
keep if exit_plaza=="WT06"
gen reliabilityML=dist/p20_speedML-dist/p50_speedML
gen reliabilityHV=dist/p20_speedHV-dist/p50_speedHV
gen reliability_diff=reliabilityML-reliabilityHV

keep if WTP2>0&WTP2~=.
keep if reliability_diff~=.
drop if TT_dif_hr==.
drop if TT_dif_hr<=0
gen time=hour+min/60+sec/(60*60)
g monthgroup=cond(date<td(04apr2013),1, ///
		cond(entry_month==5,2, ///
			cond(entry_month==8,3,.)))
kdensity time , kernel(epa) gen(t1_all epa_all) bw(.05) nograph n(100)
kdensity time if monthgroup==1, kernel(epa) gen(t1_1 epa_1) bw(.05) nograph n(100)
kdensity time if monthgroup==2 , kernel(epa) gen(t1_2 epa_2) bw(.05) nograph n(100)
kdensity time if monthgroup==3 , kernel(epa) gen(t1_3 epa_3) bw(.05) nograph n(100)
kdensity TT_dif_hr , kernel(epa) gen(tt1_all epac_all) bw(.05) nograph n(100)
kdensity TT_dif_hr  if monthgroup==1, kernel(epa) gen(tt1_1 epac_1) bw(.05) nograph n(100)
kdensity TT_dif_hr  if monthgroup==2, kernel(epa) gen(tt1_2 epac_2) bw(.05) nograph n(100)
kdensity TT_dif_hr  if monthgroup==3, kernel(epa) gen(tt1_3 epac_3) bw(.05) nograph n(100)


graph twoway (line epac_all tt1_all if tt1_all>0, lcolor(gray) lpattern(solid) lw(thick)) ///
	(line epac_1 tt1_1 if  tt1_1>0, lcolor(black) lpattern(solid)) /// 
	(line epac_2 tt1_2 if tt1_2>0, lcolor(black) lpattern(dash) ) /// 
	(line epac_3 tt1_3 if  tt1_3>0, lcolor(gray) lpattern(dot) ) ///
	, /// 
	xtitle("Travel Time Savings in Hours")  ytitle("Smoothed Density") ///
		legend(label(2 "First Month") label(3 "Third Month") label(4 "Sixth Month") label(1 "Full Sample") ///
	ring(0) position(2) rows(4) cols(1) region(lwidth(none))) 
